#pragma once
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <fcntl.h>
#include <cstdint>
#include <string>
#include <mutex>
#include <unistd.h>



namespace HAL
{
    class I2C_Master
    {
        public:
            I2C_Master(const std::string &dev);
            ~I2C_Master();
            int ReadReg(uint8_t addr, uint8_t reg, uint8_t *data, size_t len);
            int WriteReg(uint8_t addr, uint8_t reg, uint8_t *data, size_t len);

        private:
            std::string dev;
            std::mutex mtx;
            int fd = -1;
    };
}